﻿using ACM.MES.BasicManagement.Users.Dtos;
using ACM.MES.FileManagement.Files;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;

namespace ACM.MES.工序
{
    public class OperationService : CrudAppService<Operation, OperationDto, Guid, PagedAndSortedResultRequestDto, CreateUpdateOperationDto> ,IOperationService  
    {
        private readonly IOperationRepository _operationRepository;
        private readonly OperationManager _operationManager;

        public OperationService(
            IOperationRepository operationRepository,
            OperationManager operationManager) : base(operationRepository)
        {
            _operationRepository = operationRepository;
            _operationManager = operationManager;
        }


        public override async Task<OperationDto> CreateAsync(CreateUpdateOperationDto input)
        {
            var author = await _operationManager.CreateAsync(
                        input.OpCode,
                        input.Description,
                        input.Remark
                    );

            await _operationRepository.InsertAsync(author);

            return ObjectMapper.Map<Operation, OperationDto>(author);

        }
    }
}
